import type { RowType } from '#/views/onlineDesign/defaultFields/defaultFields.data';

import { requestClient } from '#/api/request';

export namespace GenDefaultFieldsTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function genDefaultFieldsQueryPageListApi(
  params: GenDefaultFieldsTableApi.PageListFetchParams,
) {
  return requestClient.get('/gen/defaultFields/queryPageList', {
    params,
  });
}

/**
 * 列表查询
 */
export async function genDefaultFieldsQueryListApi(
  params: GenDefaultFieldsTableApi.ListFetchParams,
) {
  return requestClient.get('/gen/defaultFields/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function genDefaultFieldsQueryByIdApi(
  params: GenDefaultFieldsTableApi.IdFetchParams,
) {
  return requestClient.get('/gen/defaultFields/queryById', { params });
}

/**
 * 新增
 */
export async function genDefaultFieldsAddApi(
  params: GenDefaultFieldsTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/gen/defaultFields/add', params);
}

/**
 * 编辑
 */
export async function genDefaultFieldsEditApi(
  params: GenDefaultFieldsTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/gen/defaultFields/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function genDefaultFieldsDelApi(id) {
  return requestClient.delete<boolean>(`/gen/defaultFields/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function genDefaultFieldsDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(
    `/gen/defaultFields/deleteBatchByIds/${ids}`,
  );
}
